home *** CD-ROM | disk | FTP | other *** search
- $VER: MiamiSDK 2.11 (30.12.97)
-
- © Copyright 1997 Nordic Global Inc. (kruse@nordicglobal.com)
- All rights reserved.
-
- Please see the enclosed files COPYRIGHT and DISTRIBUTION for
- more information on copyright and distribution status.
-
-
-
- Miami Software Development Kit
- ------------------------------
-
- This archive contains all files required to develop application
- software for Miami (and other compatible TCP/IP protocol stacks)
- with SAS/C, for use with AmigaOS.
-
- If you have previously used other development kits (e.g. the kit
- for AmiTCP/IP) then please read this file carefully. There are some
- differences that you need to be aware of.
-
-
-
- Installation
- ------------
-
- No specific installation is required. Just unarchive the files
- anywhere you like. HOWEVER...
-
- ...DO NOT copy the C header files over your existing files (in
- the "include:" directory).
-
- ...DO NOT copy the libraries over your existing libraries (in
- the "lib:" directory).
-
- ...DO NOT copy any of the files in this archive "over" your
- existing AmiTCP/IP developer kit (if you have one installed).
- Instead start over in a separate directory. DO NOT mix files from
- this developer kit with files from other developer kits.
-
-
- Also, many makefiles require you to create one or more of the
- assigns
-
- "assign netinclude: netinclude"
-
- "assign netlib: netlib"
-
-
- These assigns are recommended, and the remainder of this document
- assumes that these assigns exist.
-
-
-
- Usage notes
- -----------
-
- - At the moment only SAS/C is officially supported. You might be
- able to use other C compilers as well, if you make the necessary
- adaptations yourself. See the section "C compiler notes"
- below.
-
- - In addition to ordinary 680x0 binaries this developer kit can
- also be used to create PPC ELF binaries for the Phase-5
- PowerUP kernel, which directly use network calls. You need
- the PPC version of SAS/C for this. At the moment the inline
- functions of the developer kit transparently transfer all
- network calls to the 680x0 side, but this behavior may change
- in the future if/when more parts of the protocol stack are
- implemented in native PPC code.
-
- - Your compiler must use 32-bit integers (default for SAS/C).
- 16-bit integers or 64-bit integers are not supported. The
- MiamiSDK uses "long" in many places where other header files
- use "int". This change is intended to make 16-bit-integer or
- 64-bit-integer support possible in a future version (by making
- function call parameters and C structures independent of your
- C compiler's integer settings), probably in combination with
- yet another, but compatible, type change (for Posix.1g).
-
- The current drawback of this change from "int" to "long" is
- that you may occasionally get warnings 88 ("argument type
- incorrect") regarding "int *" vs "long *", in particular
- for functions like getsockopt(). Either ignore the warnings
- or change the corresponding objects in your code from "int"
- to "long" (which is what they should have been declared as
- in the first place, really...)
-
- - This developer kit supports the following APIs:
-
- - bsdsocket.library (AmiTCP/IP-compatible, with some
- extensions for multicasting, T/TCP, IPv6, new socket options
- etc.).
-
- - usergroup.library (AmiTCP/IP-compatible)
-
- - miami.library: functions specifically for Miami (name
- starting with Miami...()).
-
- - miami.library: general network functions which are part
- of the Posix.1g DNI/Socket standard, but not part of the
- bsdsocket API (e.g. inet_pton/ntop(), getaddrinfo() etc.).
-
- - miamibpf.library: BPF (Berkely Packet Filter) for use with
- Miami.
-
- - miamipcap.library: libpcap, a packet capture library for
- use with Miami and miamibpf.library.
-
- The developer kit is IPv6-ready, even though IPv6 is not
- currently supported by any AmigaOS protocol stack. This means
- if you use MiamiSDK now to develop your programs, and follow
- all guidelines regarding protocol independence, then your
- programs will automatically be IPv6-compatible once IPv6-
- supporting TCP/IP stacks appear for AmigaOS.
-
- - Programs built with the Miami Software Development Kit are
- NOT restricted to Miami. They will also work with other
- protocol stacks such as AmiTCP/IP, TermiteTCP etc., in the
- same way as if you had built the programs with the AmiTCP/IP
- native developer kit.
-
- Obviously, if your program requires Miami-specific
- features such as Multicasting, T/TCP or functions in
- miami.library or any other library only provided by Miami
- then it will only work with Miami, not with other stacks,
- unless other stacks provide Miami emulation libraries in
- the future.
-
- - The Miami Software Development Kit contains support for
- several features available only in Miami, and not accessible
- through the AmiTCP/IP native developer kit (such as Multicasting
- and T/TCP). If you use this Miami Software Development Kit
- then you do NOT need older Miami development archives (in
- particular the file "ttcp.h") any more, which were intended
- as add-ons for the AmiTCP/IP NDK.
-
- - The Miami Software Development Kit is based on 4.4BSD, not
- on earlier BSD versions like other development kits. For the
- majority of programs this should NOT cause any compatibility
- problems. However some names of C header files have changed,
- as well as the location where individual symbols are defined,
- usually in the same way things have changed in BSD from
- version 4.3 to 4.4.
-
- - The Miami Software Development Kit ONLY contains actual
- networking functions, NOT most of the non-networking Unix
- functions found in other kits (e.g. ixemul/ixnet).
-
- If your sources currently need any of these functions then
- you should rewrite the sources to use equivalent AmigaOS
- functions instead. Alternatively you could get the required
- functions from other sources.
-
- - You might notice that, unlike Unix header files, in this kit
- each header file automatically includes all other header files
- it requires, just like AmigaOS header files. This should greatly
- simplify things for you, and often means that you do NOT have
- to include OS-specific files (like <exec/types.h>) or very
- generic files (like <sys/types.h>) manually any more.
-
- - Some of the data structures in header files were not naturally
- aligned, and have been replaced with new versions which are
- naturally aligned, and are thus compatible with PPC kernels.
- Old versions were renamed by adding a "_u" suffix to the
- original names. The following structures and corresponding
- access functions were affected by this change, and require
- changes in applications:
-
- - libraries/usergroup.h:
- new, aligned: struct UserGroupCredentials,
- miami.library/MiamiGetCredentials()
- old, unaligned: struct UserGroupCredentials_u,
- usergroup.library/getcredentials()
-
- If you intend to use your program with PPC kernels or a PPC
- API translator then you MUST use the new versions of those
- structures and the new access functions. However these new
- versions are not compatible with older protocol stacks. This
- means if you want your program to work with older protocol
- stacks then use the old versions. If you want both (PPC
- compatibility AND compatibility with older protocol stacks)
- then use the old versions in 68k code, and the new versions
- in PPC code (via conditional compilation).
-
- Also the following structures were changed for correct
- alignment, but without providing new access functions or
- backward-compatibility. This should not be a problem
- for application programmers, because those structures are
- only used by routing sockets, and except for tools that
- shipped with Miami no old software should be using routing
- sockets anyway. If you want to use routing sockets in your
- software then you need to require miami.library >= V12.
-
- - net/route.h: struct rt_msghdr
- - net/if.h: struct if_msghdr, struct ifa_msghdr
-
- - Normally libraries are opened automatically for you. All
- you need to do is include the right "proto" header file in
- your source files, e.g. <proto/miami.h> for "miami.library".
- In this case DO NOT define "struct Library *MiamiBase;"
- in your code.
-
- - If libraries are opened automatically for you then the
- default minimum library versions are as follows:
-
- bsdsocket.library V4
- miami.library V12
- miamibpf.library V1
- miamipcap.library V3
- usergroup.library V4
-
- This means AmiTCP/IP 4.x or higher or Miami 1.x or higher is
- required. If you access any functions in miami.library then
- Miami 3.0 or higher is required.
-
- If you want to support older versions of those protocol
- stacks then you can manually override the minimum library
- versions in the following global variables. Examples:
-
- unsigned long _MiamiVersion=12;
- unsigned long _MiamiBPFVersion=1;
- unsigned long _MiamiPCapVersion=3;
- unsigned long _SocketVersion=4;
- unsigned long _UserGroupVersion=4;
-
- - If libraries are opened automatically for you then the global
- variables "errno" and "herrno" are automatically linked to the
- corresponding variables in the TCP/IP kernel (socket.library
- and usergroup.library), i.e. after calling functions in these
- libraries those variables in your program reflect the current
- error status.
-
- However this mechanism only works with 680x0 binaries, NOT
- with PPC binaries, because with the current PPC kernel
- sharing variables would cause a major decrease in
- performance. To check error conditions from PPC binaries you
- need to use the functions Errno() and ug_GetErr(). DO NOT
- try to set up variable sharing manually (via UGT_ERRNOPTR
- or SBTC_ERRNOPTR), because that mechanism does not work
- reliably with PPC binaries because of CPU cache
- inconsistencies.
-
- - If you do NOT want to use the "auto-open libraries"
- feature, but want to open the libraries yourself, then
- define the corresponding library bases in your program
- and open/close the libraries manually, e.g.
-
- struct Library *MiamiBase=0;
-
- /* ... */
-
- MiamiBase=OpenLibrary(MIAMINAME,12);
-
- /* ... */
-
- CloseLibrary(MiamiBase);
-
- Note that in this case you might have to do some additional
- setup, which the auto-open code usually does for you
- (SocketBaseTags(), ug_SetupContextTags()), in particular if
- you want "errno" to automatically reflect the error code of
- socket calls. Please see Socket.doc and UserGroup.doc for
- more information on this.
-
- - If you are using the small data model with 680x0 binaries
- then add the compiler options
- "INCDIR=netinclude: LIB netlib:miami.lib". For the large data
- model with 680x0 binaries add
- "INCDIR=netinclude: LIB netlib:miaminb.lib". For PPC binaries
- use the compiler option "INCDIR=netinclude:" and add the
- library "netlib:miamippc.a" to your linker call after all
- program binaries, and before "lib:scppc.a".
-
- - Example:
-
- /* for 680x0: sc INCDIR=netinclude: LIB netlib:miami.lib LINK test.c */
- /* for PPC: scppc INCDIR=netinclude: OBJNAME=test.oppc test.c
- ppc-amigaos-ld -r -o test.elf lib:c_ppc.o
- test.oppc netlib:miamippc.a lib:scppc.a lib:end.o */
-
- #include <proto/socket.h>
- #include <sys/socket.h>
-
- void main(void) {
- int s;
- s=socket(AF_INET,SOCK_STREAM,0);
- /* some more code */
- CloseSocket(s);
- }
-
- - NOTE: Library bases MAY NOT be shared among processes, i.e. if
- more than one process in your program accesses network
- libraries then you MAY NOT use global library bases (and
- auto-opening of libraries). Instead use local library bases and
- open the libraries manually, e.g.
-
- void func(void) {
- int s;
- struct Library *SocketBase;
- if(SocketBase=OpenLibrary(SOCKETNAME,4)) {
- s=socket(AF_INET,SOCK_STREAM,0);
- /* some more code */
- CloseSocket(s);
- CloseLibrary(SocketBase);
- }
- }
-
- - It is possible to make use of Miami's additional functions
- (in particular the IPv6 compatibility) without sacrificing
- compatibility with older protocol stacks, if you use runtime
- checks, e.g. like this:
-
- Define "MiamiBase" yourself, so the auto-open code does not
- try to open the library (and then complain if it cannot find
- it):
-
- struct Library *MiamiBase=0;
-
- Try to open miami.library yourself, but don't quit if it does
- not work:
-
- MiamiBase=OpenLibrary("miami.library",0);
-
- Use old-style socket access for older stacks, and new style
- (protocol-independent) access for Miami >= 3.0:
-
- if(MiamiBase&&(MiamiBase->lib_Version>=12)) {
- /* use getaddrinfo() here to resolve the server name,
- then call socket() with the returned family (IPv4
- or IPv6) */
- } else {
- /* use gethostbyname() here to resolve the server name,
- then call socket() with AF_INET (IPv4 only) */
- }
-
- At the end of your program close MiamiBase manually:
-
- if(MiamiBase) {
- CloseLibrary(MiamiBase);
- MiamiBase=0;
- }
-
- Similar methods can be used to support T/TCP in Miami. See
- the file "examples/ttcptest.c" for more details on this.
-
- Also read the note above regarding alignment problems in
- data structures and effects on PPC compatibility.
-
- - This developer kit does not contain the header files necessary
- to access MiamiSSL. If you would like to add SSL support to your
- program then please contact "kruse@nordicglobal.com" to get the
- MiamiSSL developer kit.
-
- - The AmiTCP/IP developer kit has some header files in the
- directory "amitcp". Corresponding files for the Miami SDK are
- in the directory "bsdsocket", i.e. you need to e.g. include
- <bsdsocket/socketbasetags.h> instead of <amitcp/socketbasetags.h>.
-
- - If you are new to TCP/IP programming then please have a look at
- the file "help/TCPIP.guide". It contains explanations about
- differences between Unix network programming and Amiga network
- programming, and can be used as a tutorial on TCP/IP, in
- combination with the text book mentioned in that file
-
-
-
- C compiler notes
- ----------------
-
- Currently only SAS/C is officially supported. The header files
- should be sufficiently portable to work with other compilers
- as well, except possibly for the way "time.h" is included by
- "sys/time.h". (This weirdness is caused by some compatibility
- problems between structures in AmigaOS and BSD.)
-
- However there are a few other possible compatibility issues:
-
-
- - The following rules need to be observed if you want to compile
- 680x0 and PPC binaries with SAS/C from the same sources:
-
- - Varargs versions of library calls currently cannot be used.
- This means you need to use vsyslog() instead of syslog(),
- SocketBaseTagList() instead of SocketBaseTags() etc.
-
- - Don't assume that errno and herrno are set automatically
- for you. Get the error status manually, by calling
- Errno(), ug_GetErr() etc.
-
- - Don't use struct UserGroupCredentials_u, or any
- functions that accept or return that structure.
-
- - For 680x0 binaries most functions are accessed through
- #pragma calls only, i.e. no function stubs exist, except
- for those functions which cannot be called directly through
- a #pragma call (see below). If your compiler does not support
- SAS/C-compatible #pragma calls then you need to modify the
- #pragma calls or create your own function stubs from the
- #pragma calls or from the enclosed fd-files. For PPC binaries
- inline functions are used to call the PowerUp kernel and
- transfer control to the 680x0 side.
-
- - Functions which pass or return structures as parameters cannot
- be used in conjunction with 680x0 #pragma calls, so function
- stubs are provided for them in miami.lib and miaminb.lib. The
- critical functions which require function stubs are:
-
- - inet_lnaof
- - inet_makeaddr
- - inet_netof
- - inet_ntoa
- - select (which really maps to WaitSelect())
-
- Note that the way a C compiler passes or returns structures
- is NOT standardized. Your compiler may very well do this in
- a different way than SAS/C does, so the function stubs in
- miami.lib and miaminb.lib might not work with your compiler.
-
- - The library-auto-open feature is specific to SAS/C (using
- _STI... and _STD... functions). It ONLY works if you use the
- standard SAS/C startup code, and probably will not work
- with other compilers at all. It works both with 680x0
- binaries and with PPC binaries.
-
- *EOF*
-